<?php
namespace Content\Controller;
use Common\Controller\AdminbaseController;
class CacheController extends AdminbaseController 
{   

	public function index()
	{
		$runtime= constant("RUNTIME_PATH");
        $cachePath=$runtime.'Cache/';
        if (is_dir($cachePath))
        {
            if ($dh = opendir($cachePath))
            {   
                while (($file = readdir($dh)) !== false)
                {
                    if($file!="." && $file!="..") 
                    {
                        $file = iconv("gb2312","UTF-8",$file);
                        $file=$cachePath.$file;
                        $this->deldir($file);
                    }
                }
                closedir($dh);
            }

        }
        $this->cache();
		
	}
    function deldir($dir) 
    {
      //先删除目录下的文件：
      $dh=opendir($dir);
      while ($file=readdir($dh)) {
        if($file!="." && $file!="..") {
          $fullpath=$dir."/".$file;
          if(!is_dir($fullpath)) {
              unlink($fullpath);
          } else {
              deldir($fullpath);
          }
        }
      }
 
      closedir($dh);
      //删除当前文件夹：
      if(rmdir($dir)) {
        return true;
      } else {
        return false;
      }
    }
	public function cache()
	{

		$this->display('cache');
	}
}
?>